﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BUS;

public partial class AccountDetails : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

        if (Request.QueryString["user"] != null && !IsPostBack)
        {
            var userEnCrypt = Request.QueryString["user"];
            var userSession = (string)Session["user"];
            if (userEnCrypt == userSession.EncryptMD5())
                DisplayInfoUser(userSession);
            else            
                ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('Bạn không có quyền xem trang này');window.location='Default.aspx';", true);            
        }

    }

    private void DisplayInfoUser(string userName)
    {
        var kh = new KhachHangBUS() { TenDangNhap = userName };
        if (kh.GetbyUserName())
        {
            lblTenDangNhap.Text = kh.TenDangNhap;
            lblHoTen.Text = kh.HoTen;
            lblDiaChi.Text = kh.DiaChi;
            lblSoDienThoai.Text = kh.SoDienThoai;
            lblEmail.Text = kh.Email;
            lblCMND.Text = kh.CMND;
            lblCauHoi.Text = kh.CauHoi;
            lblTraLoi.Text = kh.TraLoi;
        }
    }
}